<template>
	<view class="container">
		<!--  #ifdef  APP-PLUS-->
		<uni-nav-bar fixed='true' @clickLeft='back' statusBar='true' style="width: 100%;">
		
			<view slot='left'>
				<text class="cuIcon-back"></text>
		
			</view>
			<view class="status-center padding-left center bg-F4F4F4  round" style="height: 70rpx;margin-left: -30px;">
				<image :src="baseUrl + '/static/search_for.png'" mode="" style="width: 25rpx;height: 25rpx;">
				</image>
				<input type="text" @input='handSearch' value="" class="text-13 f-grow1 padding-left-sm"
					placeholder="搜索姓名、手机号" />
			</view>
		
		</uni-nav-bar>
		<!--  #endif -->
		<!--  #ifdef     MP-WEIXIN -->
		<view class="bg-white">
			<kg-custom :isBack="true" bgColor="bg-white">
				<block slot="left">
					<view class="flex justify-start align-center bg-F4F4F4 padding-left round margin-left-sm"
						style="height: 70rpx;width: 460rpx;">
						<image :src="baseUrl + '/static/search_for.png'" mode="" style="width: 25rpx;height: 25rpx;">
						</image>
						<input type="text" @input='handSearch' value="" class="text-13 f-grow1 padding-left-sm"
							placeholder="搜索姓名、手机号" />
					</view>
				</block>
			</kg-custom>

		</view>
			<!--  #endif -->
		<view class="padding margin-sm bg-white flex justify-start radius10" v-for="(item,index) in list" :key='index'>
			<image :src="item.icon" mode="" class="round cu-avatar"></image>
			<!-- @click.stop="toPage('/filePage/pages/detail-or-order/detail-or-order')" -->
			<view class="margin-left-sm f-grow1">
				<view class="flex justify-between align-center">
					<view class="text-bold text-181818 text-xl">
						{{item.userName}}
					</view>
					<block v-if='type==1'>
						<view class="text-sm color" v-if='item.level==1'>
							初级技工
						</view>
						<view class="text-sm color" v-if='item.level==2'>
							中级技工
						</view>
						<view class="text-sm color" v-if='item.level==3'>
							高级技工
						</view>
					</block>
					
				</view>
				<view class="flex justify-start align-center text-sm text-666 margin-top-sm">
					<view class="">
						接单量<text class="text-15 margin-left-xs">{{item.orderServiceCount}}</text>
					</view>
					<view class="margin-left">
						收入<text class="text-15 text-FF3636 margin-left-xs"> ¥{{item.orderTotalAmount}}</text>
					</view>
				</view>
				<view class="flex justify-between align-center text-sm text-999" style="margin-top: 60rpx;">
					<view class="">
						加入时间 {{item.auditTime}}
					</view>
					<view class="margin-left">
						电话:{{item.userMobile}}
					</view>
				</view>
				<view class="margin-top flex justify-end align-center">
					<button @click="toPage('/filePage/pages/invite/invite?item='+encodeURIComponent(JSON.stringify(item)) +'&type='+type)"
						class="bg-color text-13 text-white btn round">
						<block>详情</block>
					
					</button>
				</view>
			</view>
		</view>

		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from '@/common/util/BetterPull'
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = 'loading';

					const obj = {
						pageNum: page,
						pageSize: 10,
						mechanicAuditStatus: this.mechanicAuditStatus,
						shopNullFlag: 1

					}
					let api = ''
					if (this.userMobile) {
						obj.userMobile = this.userMobile
					}
					if (this.userName) {
						obj.userName = this.userName
					}
					if (this.type==2) {
						api = 'courierList'
					} else if(this.type==1) {
						api = 'mechanic'
					} 
					console.log(api)
					const [err, res] = await this.$get(this.$api[api],
						obj)
					if (res) {
						var data = res.data.list
						if (this.mechanicAuditStatus == 0) {
							this.merNum = res.data.total

						} else {
							this.merNumEd = res.data.total
						}
						console.log(this.merNum)
						done(data);
						if (data.length < 10) {
							this.loading = 'noMore';
						} else {
							this.loading = 'more';
						}

					}
					if (err) {
						done([]);
						this.loading = 'noMore';
					}
				}
			})
		],

		data() {
			return {
				baseUrl: this.$config.baseUrl,
				loading: 'more',
				userName: '',
				userMobile: '',
				mechanicAuditStatus: 1,
				merNum: 0,
				merNumEd: 0,
				reFreshStatus: "",
				shopId: '',
				// status: false,
				type:''
			};
		},

		watch: {
			//监听reFreshStatus,如果有修改就执行监听器
			reFreshStatus() {
				this.mechanicAuditStatus = 1
				this.merNum = 0
				this.Refresh();
				console.log("页面已重新加载");
			}
		},
		onLoad(options) {
		   console.log(options)
		   if(options.type){
			    this.type = options.type
				// if(this.type==1){
				// 	 this.status = false
				// }else if (this.type==2){
				// 	this.status = true
				// }
		   }
		  
		   
		},
		

		methods: {
			back() {
				console.log(1111)
				uni.navigateBack({
			
				})
			},
			toPage(url) {
				console.log(url)
				this.$util.openNewPage(url)
			},

			handSearch(e) {
				this.userMobile = ''
				this.userName = ''
				var n = Number(e.detail.value);
				if (!isNaN(n)) {
					this.userMobile = n
				} else {
					this.userName = e.detail.value
				}
				// console.log(this.userName)
				this.Refresh();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		padding: 4rpx;

		.tab {
			width: 350rpx;
			padding: 16rpx;
		}

		.on {
			background: #fff;
			color: #ED7200;
			font-weight: bold;
		}
	}

	.footer {
		position: fixed;
		left: 20rpx;
		right: 20rpx;
		bottom: 98rpx;

		image {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.btn {
		padding: 20rpx 50rpx;
	}
	.status-center {
		width: 460rpx;
		display: flex;
		align-items: center;
	}
</style>
